package come.bjpowernode.javase.threadsafe2;

public class Test {
    public static void main(String[] args) {
        //创建账户对象
        Account act = new Account("001",10000);

        //创建两个线程
        Thread t1 = new AccountThread(act);
        Thread t2 = new AccountThread(act);

        //如果synchronized(this)或者actno、obj1等，t1、t2会排队，t3不会排队。
        //如果synchronized("abc")，t1、t2、t3都会排队.
        Account act2 = new Account("001",10000);
        Thread t3 = new AccountThread(act2);


        //设置name
        t1.setName("t1");
        t2.setName("t2");
        t3.setName("t3");

        //启动线程
        t1.start();
        t2.start();
        t3.start();


    }
}
